public class t213 {
    public static void main(String[] args) {
        int arr [] = {200,3,140,20,10};
        int n = arr.length;
        /*if(n == 1){
            return arr[0];
        }
        if(n == 2){
            return Math.max(arr[0],arr[1]);
        }*/
        int dp [] = new int [n];
        dp[0] = arr[0];
        dp[1] = Math.max(arr[0],arr[1]);
        int max = 0;
        for(int i = 2;i<n-1;i++){//偷首
            dp[i] = Math.max(dp[i-1],dp[i-2]+arr[i]);
        }
        max = dp[n-2];
        //System.out.println(max);


        dp[1] = arr[1];
        dp[2] = Math.max(arr[1],arr[2]);
        for(int i =3;i<n;i++){
            dp[i] =Math.max(dp[i-1],dp[i-2]+arr[i]);
        }
        int max2 = dp[n-1];
        //return Math.max(max,max2);
        System.out.println(Math.max(max,max2));

    }
}
